
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>食哩哩售货机管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/admin/css/index.css" media="all">
    <script>
        /^http(s*):\/\//.test(location.href) || alert('请先部署到 localhost 下再访问');
    </script>

</head>

<body>
<div class="bgCls"></div>
<div class="wrap layui-form">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px">
        <legend class="title" style="font-size: 2em; font-weight: bold;">食哩哩售货机管理系统</legend>
    </fieldset>
    <div class="layui-form-item" style="margin-top: 34px !important;">
        <label class="layui-form-label">用户账号</label>
        <div class="layui-input-block">
            <input type="text" id="phone" name="phone" lay-verify="required|phone" autocomplete="off" style="width: 280px"
                   placeholder="请输入用户账号" class="layui-input" value="">
        </div>
    </div>
    <div class="layui-form-item" style="margin-top: 34px !important;">
        <label class="layui-form-label">登录密码</label>
        <div class="layui-input-block">
            <input type="password" id="password" name="password" placeholder="请输入登录密码" style="width: 280px" autocomplete="off"
                   class="layui-input" value="" lay-verify="required|password">
        </div>
    </div>
    <div class="content" style="margin-top: 40px">
        <div id="loginId" class="layui-btn layui-btn-normal" style="width: 20em;border-radius: 5px;cursor: pointer" lay-submit lay-filter="formLogin">登录
        </div>
    </div>
</div>
<script src="/admin/layui/layui.js"></script>
<script>
    layui.use(['table','jquery','element','form','layer'], function(){
      var $ = layui.jquery,element = layui.element,layer = layui.layer,form = layui.form;
        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,password: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听提交
        form.on('submit(formLogin)', function(data){
            $.ajax({
                type: "POST",
                url: '/admin/adminLogin',
                async:false,//同步提交。不设置则默认异步，异步的话，最后执行ajax
                data:{
                  phone: $("#phone").val(),
                    password:$("#password").val()
                },
                success: function(result) {
                    console.log(result);
                    if(result && result.data){
                        var map = result.data;
                        self.location = map.redirectUrl;
                        // self.location = "https://open.youzan.com/oauth/authorize?client_id=b79f253d95ca108956&response_type=code&state=machineCode";
                    }else{
                        layer.alert("手机号或密码错误！");
                    }
                },
                error: function(error) {
                    alert(error.status);
                }
            });
        });
    })
</script>
</body>
</html>


